import java.util.*;


public class LadderSnake {

	public static void main(String[] args) {
		
		Set<Integer> visited=new HashSet<Integer>();
		Set<Integer> isInQueue=new HashSet<Integer>();
		Queue<Integer> cellQueue= new LinkedList<Integer>();
		Cell cellArray[]=new Cell[37];

		int snakesAndLadders[]= new int[37];
		snakesAndLadders[3]=16;
		snakesAndLadders[5]=7;
		snakesAndLadders[18]=20;
		snakesAndLadders[15]=25;
		snakesAndLadders[21]=32;

		snakesAndLadders[12]=2;
		snakesAndLadders[17]=4;
		snakesAndLadders[14]=11;
		snakesAndLadders[35]=22;
		snakesAndLadders[31]=19;
		
		cellQueue.add(new Integer(1));
		cellArray[1]= new Cell(1,Cell.ArriveType.byDice);
		boolean found= false;
		while(!cellQueue.isEmpty()&&!found)
		{
			int currentCell=cellQueue.remove();
			if (!visited.contains(currentCell))
			{
				visited.add(new Integer(currentCell));
				for (int i=1;i<=6;i++)
				{
					if (!visited.contains(currentCell+i))
					{						
						cellArray[currentCell+i]= new Cell(currentCell,Cell.ArriveType.byDice);
						if (snakesAndLadders[currentCell+i]!=0)
						{
							visited.add(currentCell+i);
							if(!isInQueue.contains(snakesAndLadders[currentCell+i]))
							{
								cellQueue.add(snakesAndLadders[currentCell+i]);
								isInQueue.add(snakesAndLadders[currentCell+i]);
								cellArray[snakesAndLadders[currentCell+i]]= new Cell(currentCell+i,(snakesAndLadders[currentCell+i]>(currentCell+i))?Cell.ArriveType.byLadder:Cell.ArriveType.bySnake);
							}		
						}
						else
						{
							if(!isInQueue.contains(currentCell+i))
							{
								cellQueue.add(currentCell+i);
								isInQueue.add(currentCell+i);
							}
						}
						if ((snakesAndLadders[currentCell+i]==36)||(currentCell+i==36))
						{
							found = true;
							break;
						}
					}		
				}
			}
		}
		int currentCell=36;
		Stack<String> strStack=new Stack<String>();

		do
		{
			strStack.add(cellArray[currentCell].getComeFrom()+" TO "+currentCell+" BY "+cellArray[currentCell].getArriveType());
			currentCell = cellArray[currentCell].getComeFrom();
		}while(currentCell!=1);
		
		while(!strStack.isEmpty())
		{
			System.out.println(strStack.pop());			
		}
	}
}
